package main

import (
	"fmt"
)

func QuickSort(left int, right int, array *[6]int) {
	l := left
	r := right
	pivot := array[(left + right) / 2]
	for l < r {
		for array[l] < pivot {
			l++
		}
		for array[r] > pivot {
			r--
		}
		if l >= r {
			break
		}
		array[l], array[r] = array[r], array[l]
		if array[l] == pivot {
			r--
		}
		if array[r] == pivot {
			l++
		}
	}
	if l == r {
		l++
		r--
	}
	if left < r {
		QuickSort(left, r, array)
	}
	if right > l {
		QuickSort(1, right, array)
	}
}


func main() {

	arr := [6]int {-9, 78, 0, 23, -567, 70}
	QuickSort(0, len(arr) - 1, &arr)
	fmt.Println(arr)


}